package com.artpri.dao.impl;

import java.util.List;

import org.hibernate.transform.Transformers;

import com.artpri.dao.ShopCartVoDao;
import com.artpri.model.vo.ShopCartVo;

/**
 * 
 * @author ZhangSi
 *
 */
public class ShopCartVoDaoImpl extends HibernateDaoImpl<ShopCartVo> implements ShopCartVoDao{

	@SuppressWarnings("unchecked")
	@Override
	public List<ShopCartVo> findShopCartVoByUser(Integer userNum) {

		String sql = "select c.cart_id cartId, s.shopkeeper_num shopkeeperNum, s.sk_name skName"
				+ ", c.goods_num goodsNum, g.goods_name goodsName, g.goods_describe goodsDescribe, a.ga_path gaPath"
				+ ", c.cart_num cartNum, g.goods_price goodsPrice, c.create_time createTime "
				+ "from shop_cart c join goods g on c.user_num=?0 and c.goods_num=g.goods_num "
				+ "join goods_album a on a.goods_num=g.goods_num and a.ga_main=1 "
				+ "join shopkeeper_info s on s.user_num=c.user_num";
		
		return getSqlQuery(sql, userNum).setResultTransformer(Transformers.aliasToBean(ShopCartVo.class)).list();
	}

}
